<!doctype html>
<html lang="en">

<head>
    <meta charset="UTF-8">
        <title>商品详情-${_front_title}</title>
	<meta name="keywords" content="${_front_keywords}" />
    <meta name="description" content="${_front_description}" />
    <link rel="shortcut icon" href="/static/favicon.ico"/>
    <link rel="stylesheet" href="${_front_css}/base.css">
    <link rel="stylesheet" href="${_front_css}/mall_point.css">
    <link rel="stylesheet" href="${_front_css}/wan-spinner.css">
	<script type="text/javascript" src="${_front_js}/jquery.min.js"></script>
	<script src="${_front_js}/tabs.js"></script>

</head>

<body>
<#include "../base/top.ftl"/>  
    <div class="warp2_bg">
        <div class="warp2 detail_current">
            <div class="shop_add">
                当前位置：<a href="index.html">首页</a> &gt;
                <a href="javascript:">积分商城</a> &gt;
                <#if good.name?exists>
                	<span>${good.name}</span>
                </#if>
            </div>
        </div>
        <div class="warp2 detail_list">
            <div class="shop_info_pic">
            	<#if good.path?exists>
                	<img src="${good.path}" border="0">
                </#if>
            </div>
            <div class="shop_info_font">
                <ul>
                    <li>
                    <#if good.name?exists>
                     <h1>${good.name}</h1>
                    </#if>
                    <h2>
	                    <#if good.typeName?exists>
	                     	${good.typeName}<br> 
	                    </#if>
                     	所需积分:
                     	<#if good.amount?exists>
                     		<span>${good.amount}</span><br>
                     	</#if>
                     	购买人数:
                     	<#if good.buyCount?exists>
                     		${good.buyCount}人<br>
                     	<#else>
                     		0人<br>
                     	</#if>
                     	剩余数量:
                     	<#if good.sum?exists>
                     		${good.sum}/个<br>
                     	<#else>
                     		0/个<br>
                     	</#if>
                     	上架日期:
                     	<#if good.publishTime?exists>
                     		${good.publishTime?string("yyyy-MM-dd")}
                     	</#if>
                     	
                    </h2>
                    <div style="float:left;margin-top:-43px;text-align:center;">购买数量：
                    	<div class="wan-spinner wan-spinner-2">
                    	<a href="javascript:void(0)" class="minus">-</a>
    						<input type="text" value="1" id="buyCount">
    					<a href="javascript:void(0)" class="plus">+</a>
    					</div></div>
                    	<h3><a <#if user??>onClick="showDetail()"<#else> href="/login"</#if> id="buy" shopid="253">立即兑换</a></h3>
                        <h4><#if user??><#else><a href="/login">请先登录</a></#if></h4></li>
                </ul>
            </div>
        </div>
        <div class="warp2 detail_content">
            <div class="shop_pinggu_lm demo">
                <ul class="tab_menu">
                    <li class="current">
                        <a href="javascript:">商品详情</a>
                    </li>
                    <li>
                        <a href="javascript:">购买记录 <#if pageInfo.total?exists>(${pageInfo.total})<#else>(0)</#if></a>
                    </li>
                </ul>
                <div class="tab_box">
                    <div class="shop_pinggu_pic shop_pinggu">
                        <#if good.content?exists>
                        	${good.content}
                        <#else>
                        	暂无该商品描述
                        </#if>
                    </div>
                    <div class="hide shop_pinggu_buy shop_pinggu" style="">
                        <div class="bar">
                            <span class="sCol1">用户</span>
                            <span class="sCol2">数量</span>
                            <span class="sCol3">兑换积分</span>
                            <span class="sCol4">购买时间</span>
                        </div>

                        <div class="buy">
                            <ul>
                            	<#if (pageInfo.pageList?size>0)>
	                            	<#list pageInfo.pageList as model>
		                            	<li>
			                            	<span class="iCol1">
				                            	<#if model.name?exists>
				                            		${model.name[0..2]}...
				                            	</#if>
			                            	</span>
			                            	<span class="iCol2">
				                            	<#if model.count?exists>
				                            		${model.count}	
				                            	</#if>
			                            	</span>
			                            	<span class="iCol3">
				                            	<#if model.score?exists>
				                            		${model.score}
				                            	</#if>
			                            	</span>
			                            	<span class="iCol4">
				                            	<#if model.buyTime?exists>
				                            		${model.buyTime?string("yyyy-MM-dd hh-mm-ss")}
				                            	</#if>
			                            	</span>
		                            	<li>
	                            	</#list>
                            	</#if>
                            </ul>
                        </div><div class="clearfix"></div> 
                        <div class="next_bk">
                            <div class="next"> 187 条记录 1/10 页    
                                <span class="current">1</span>
                                <a href="javascript:">2</a>
                                <a href="javascript:">3</a>
                                <a href="javascript:">4</a>
                                <a href="javascript:">5</a>  
                                <a href="javascript:">下一页</a> 
                                <a href="javascript:">最后一页</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
  
<#include "../base/foot.ftl"/>
<div id="msgDiv" style="margin-top: -75px;"	>
	<div id="msgShut" align="right">
		<br> <a href="#" style="color: #F85959" class="close">×</a>
	</div>
	<div id="msgDetail" class="content">
		<div class="title">选择收获地址</div>
		<#if (cnee?size>0)>
			<#list cnee as model>
			<input id="liu" style="float:left; margin-top:15px;" name="Fruit" type="radio" value="<#if model.id?exists>${model.id}</#if>"/>
				<div id="cnee" style="border:1px solid #ccc;margin-bottom: 10px;width:500px;margin-left: 35px;">
					<#if model.name?exists><span style="width:150px;text-align:left;">收货人姓名：${model.name}</span></#if>
					<#if model.phone?exists><span style="width:200px;text-align:left;">联系方式：${model.phone}</span></#if></br>
					<#if model.address?exists><span style="width:400px;text-align:left;">收货地址：${model.address}</span></#if>
				</div>
			</#list>
		</#if>
		<div style="text-align: center;">
		<input type="button" value="新增联系人" class="determine"/>
		<input type="button" value="确定" class="determine" onclick="buy()"/>
		</div>
	</div>
</div>
<div id="bgDiv"></div>
<script type="text/javascript" src="${_front_js}/layer/layer.js" ></script>
<script type="text/javascript" src="${_front_js}/layer/extend/layer.ext.js" ></script>
<script type="text/javascript" src="${_front_js}/wan-spinner.js" ></script> 
<script type="text/javascript">
$(document).ready(function() {
    var options = {
      maxValue: 10,
      minValue: -5,
      step: 0.131,
      inputWidth: 100,
      start: -2,
      plusClick: function(val) {
        console.log(val);
      },
      minusClick: function(val) {
        console.log(val);
      },
      exceptionFun: function(val) {
        console.log("excep: " + val);
      },
      valueChanged: function(val) {
        console.log('change: ' + val);
      }
    }
    $(".wan-spinner-2").WanSpinner().css("border-color", "#2C3E50");
  });
  
  
function showDetail() {
	var id = ${good.id};
	var count = $.trim($("#buyCount").val());
	if(count == ""){
		alert("请输入购买数量！");
		return;
	}
	$.ajax({
			type : "POST",
			async : 'false',
			url : "/front/good/buy",
			data : {
				count : count,
				storeid : id
			},
			success : function(result) { 
				    if(result.code==-1){
					    $("#msgDiv").attr("marginTop",(document.documentElement.scrollTop-250)+"px")
					    
					    $("#msgShut").click(function(){
					    	$("#bgDiv").hide();
					    	$("#msgDiv").hide();
					    })
				    }
			}); 
		}
	});
}

function buy() {
		var id = ${good.id};
		var count = $.trim($("#buyCount").val());
		var cnee = $('input[name="Fruit"]:checked').val();
		if(count == "" || (count<0)){
			alert("请输入购买数量！");
    		return;
		}
		$.ajax({
			type : "POST",
			async : 'false',
			url : "/front/good/confirm",
			data : {
				count : count,
				cneeId : cnee,
				storeid : id
			},
			success : function(result) { 
		        layer.alert(result.msg, function(index){
				    layer.close(index);
				    if(result.code==-1){
					 window.location.reload();
				    }
				}); 

			}
		});
	}
</script>
</body>
</html>
